package com.data.modules.wrt.controller;


import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.data.common.api.vo.Result;
import com.data.common.system.util.JwtUtil;
import com.data.modules.jd.service.IJdCarInfoService;
import com.data.modules.smzh.entity.SmRtspInfo;
import com.data.modules.smzh.service.ISmRtspInfoService;
import com.data.modules.wrt.entity.WrtAlarmLog;
import com.data.modules.wrt.entity.WrtCallLog;
import com.data.modules.wrt.entity.WrtDevice;
import com.data.modules.wrt.entity.WrtOpenLog;
import com.data.modules.wrt.service.IWrtAlarmLogService;
import com.data.modules.wrt.service.IWrtCallLogService;
import com.data.modules.wrt.service.IWrtDeviceService;
import com.data.modules.wrt.service.IWrtOpenLogService;
import com.data.modules.wrt.vo.WrtAlarmReqVo;
import com.data.modules.wrt.vo.WrtCallReqVo;
import com.data.modules.wrt.vo.WrtDeviceReqVo;
import com.data.modules.wrt.vo.WrtOpenLogReqVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @Author boot
 */

@RestController
@RequestMapping("/wrtThird")
@Api(tags="wrtThird")
@Slf4j
@SuppressWarnings("ALL")
public class WrtThirdController<stringWarnType> {

	@Autowired
	private IWrtDeviceService wrtDeviceService;

	@Autowired
	private IWrtCallLogService wrtCallLogService;

	@Autowired
	private IWrtAlarmLogService wrtAlarmLogService;

	@Autowired
	private IWrtOpenLogService wrtOpenLogService;

	@Autowired
	private IJdCarInfoService jdCarInfoService;

	@Autowired
	private ISmRtspInfoService smRtspInfoService;

	@ApiOperation(value="获取视频流地址", notes="获取视频流地址")
	@PostMapping(value = "/queryRtspInfoByAppId")
	public Result<?> queryRtspInfoByAppId(@RequestBody SmRtspInfo smRtspInfo) {

		List<SmRtspInfo> pageList = smRtspInfoService.lambdaQuery().eq(SmRtspInfo::getAppId,smRtspInfo.getAppId()).list();
		return Result.OK(pageList);
	}

	@ApiOperation("统计设备数据")
	@GetMapping("/v1/queryDeviceTotal")
	public Result<?> queryDeviceTotal() throws Exception {
		//统计设备数据
		Map map = wrtDeviceService.queryDeviceTotal();
		return Result.OK(map);
	}

	@ApiOperation("统计报警数据")
	@GetMapping("/v1/queryAlarmLog")
	public Result<?> queryAlarmLog() throws Exception {
		//统计紧急报警 和其他报警、报修
		Map map = wrtAlarmLogService.queryAlarmLog();
		return Result.OK(map);
	}

	@ApiOperation("统计人员进出总数据")
	@GetMapping("/v1/queryPersonTotal")
	public Result<?> queryPersonTotal() throws Exception {
		//统计

		int total = wrtOpenLogService.queryPersonTotal();
		return Result.OK(total);
	}

	@ApiOperation("统计人员进出实时数据")
	@GetMapping("/v1/queryMonitorPersonLog")
	public Result<?> queryMonitorPersonLog() throws Exception {
		//统计
		List<WrtOpenLog> list = wrtOpenLogService.queryMonitorPersonLog();
		return Result.OK(list);
	}

	@ApiOperation("获取AI数据")
	@GetMapping("/v1/queryAiLog")
	public Result<?> queryAiLog() throws Exception {
		//统计
		Map map = wrtOpenLogService.queryAiLog();
		return Result.OK(map);
	}

	@ApiOperation("获取车辆数据")
	@GetMapping("/v1/queryCarInfo")
	public Result<?> queryCarInfo() throws Exception {
		//统计
		Map map = jdCarInfoService.queryCarInfo();
		return Result.OK(map);
	}

	@ApiOperation("获取AI超过一天预警数据")
	@GetMapping("/v1/queryOneDayAiLog")
	public Result<?> queryOneDayAiLog() throws Exception {
		//统计
		Map map = wrtOpenLogService.queryOneDayAiLog();
		return Result.OK(map);
	}

	@ApiOperation("获取AI超过两天天预警数据")
	@GetMapping("/v1/queryTwoDayAiLog")
	public Result<?> queryTwoDayAiLog() throws Exception {
		//统计
		Map map = wrtOpenLogService.queryTwoDayAiLog();
		return Result.OK(map);
	}

	@ApiOperation("获取车辆数据")
	@GetMapping("/v2/queryCarInfo")
	public Result<?> queryCarInfoV2() throws Exception {
		//统计
		Map map = jdCarInfoService.queryCarInfo();
		return Result.OK(map);
	}

}
